package com.example.gastometro;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.pm.FeatureInfo;


import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;


public class NovoGasto extends Activity {
Button btAdicionar;
private DbAdapter datasource;

	EditText edtNome;
	EditText edtLocal;
	EditText edtValor;
	EditText edtData;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		
		
		setContentView(R.layout.activity_novo_gasto);
		
		datasource = new DbAdapter(this);
		edtNome = (EditText) findViewById(R.id.edtNome);
		edtLocal = (EditText) findViewById(R.id.edtLocal);
		edtValor = (EditText) findViewById(R.id.edtValor);
		edtData = (EditText) findViewById(R.id.edtData);
		btAdicionar = (Button) findViewById(R.id.btAdicionar);

		btAdicionar.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
			// TODO Auto-generated method stub
			datasource.open();
			Gasto g = datasource.createGasto(
			edtNome.getText().toString(),
			edtLocal.getText().toString(),
			edtValor.getText().toString(),
			edtData.getText().toString());
			datasource.close();
			AlertDialog.Builder dialogo = new
			AlertDialog.Builder(NovoGasto.this);
			dialogo.setTitle("Aviso");
			dialogo.setMessage("Gasto:" + g.getNome());
			dialogo.setNeutralButton("OK", new DialogInterface.OnClickListener()
			{
			public void onClick(DialogInterface dialog, int id){
             finish();
			}
			});
			dialogo.show();
			}
			});
	}

	 
	

}
